/*
 * ConstantesGenerales.java
 *
 * Created on 18 de julio de 2005, 12:29 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.src.computec.radar.consultas.base.constantes;
import com.src.computec.radar.base.source.CoreSource;
import com.src.computec.radar.base.util.RandomStringUtils;
import com.src.computec.radar.consultas.source.ConsultasSource;
import com.src.log4j.logger.custom.XLogger;
import java.awt.Color;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 *
 * @author Santiago
 */

public class ConstantesGenerales {
    
    private static XLogger xLogger;
    protected static ConstantesGenerales instance;
    public static Locale LOCALE_DEFAULT = Locale.getDefault();
    public static String FACTORYDAO_CLASSNAME;
    public static String SCHEMA;
    public static final String JNDINAME_BASICA_SESSION = "ejb/BasicaSessionBean";
    public static final String JNDINAME_ORDENPROCESO_SESSION = "ejb/OrdenProcesoSessionBean";
    public static final String JNDINAME_CRUCEINFORMACION_SESSION = "ejb/CruceInformacionSessionBean";
    public static final String JNDINAME_GENERARBASE_SESSION = "ejb/GenerarBaseSessionBean";
    public static DecimalFormat DECIMAL_FORMAT;   
    public static String FOLDER_CARGUE_ARCHIVOS;
    public static String PATH_ARCHIVOS_ALERTAS;
    public static String FILE_EXTENSION;
    public static String FILE_EXTENSION_ZIP;
    public static RandomStringUtils RANDOM_STRING_UTILS = new RandomStringUtils();
    public static String FILE_CODE;
    public static String DESCRIPCION_MENSAJE_ALERTA_CRUCE_INFORMACION;
    public static String FILE_ORIGIN_CRUCE_INFORMACION;
    public static String FILE_ORIGEN_CONSULTA_BASICA;
    public static String FILE_ACTIVE;
    public static String DESCRIPCION_MENSAJE_ALERTA_ORDEN_PROCESO;
    public static String DESCRIPCION_MENSAJE_ALERTA_BASE_CLIENTE;
    public static String FILE_ORIGIN_ORDEN_PROCESO;
    public static SimpleDateFormat SIMPLE_DATE_FORMAT;
    public static String FILE_SEPARATOR;
    public static String NOMBRE_CAMPO_CODIGO_BARRAS;
    public static SimpleDateFormat SHORT_SIMPLE_DATE_FORMAT;
    public static String FILE_ORIGIN_GENERAR_BASE;
    public static SimpleDateFormat SHORT_SIMPLE_DATE_FORMAT_TO_HELP;
    public static String FILE_SEPARATOR_TO_HELP;
    public static SimpleDateFormat SIMPLE_DATE_FORMAT_IMG;
    public static List LIST_LDAP_USERS_FILTER;
    public static List LIST_CODIGOS_CLIENTES_VIEW_RECLAMOS;
    public static List LIST_CODIGOS_CALL_CENTER_BANNED_RECLAMOS;
    public static String PATH_GRAFICAS;
    public static String FULL_PATH_GRAFICAS;
    public static Color LIGHT_BLUE;
    public static Color LIGHT_RED;
    public static Color LIGHT_GREEN;
    public static Color LIGHT_YELLOW;
    public static String CODIGO_GESTION_ENVIO_IMPRESION;
    public static int NUMERO_REGISTROS_ZIP;
    
    protected ConstantesGenerales() {
        this.xLogger = (XLogger) XLogger.getLogger(this.getClass().getName());
        ConsultasSource consultasSource = ConsultasSource.getInstance();
        this.LOCALE_DEFAULT.setDefault(new Locale("es", "CO"));
        this.FACTORYDAO_CLASSNAME = consultasSource.getConsultasSetupKey("DaoFactoryClassName");
        this.SCHEMA = consultasSource.getConsultasSetupKey("schema");
        this.DECIMAL_FORMAT = new DecimalFormat(consultasSource.getConsultasSetupKey("decimalFormat"));
        this.FOLDER_CARGUE_ARCHIVOS = CoreSource.getInstance().getUtilidadesSetupKey("folderCargueArchivos");
        this.PATH_ARCHIVOS_ALERTAS = consultasSource.getConsultasSetupKey("pathArchivosAlertas");
        this.FILE_EXTENSION = consultasSource.getConsultasSetupKey("fileExtension");
        this.FILE_EXTENSION_ZIP = consultasSource.getConsultasSetupKey("fileExtensionZip");
        this.FILE_CODE = consultasSource.getConsultasSetupKey("fileCode");
        this.DESCRIPCION_MENSAJE_ALERTA_CRUCE_INFORMACION = consultasSource.getConsultasSetupKey("descripcionMensajeAlertaCruceInformacion");
        this.FILE_ORIGIN_CRUCE_INFORMACION = consultasSource.getConsultasSetupKey("fileOriginCruceInformacion");
        this.FILE_ORIGEN_CONSULTA_BASICA = consultasSource.getConsultasSetupKey("fileOrigenConsultaBasica");
        this.FILE_ACTIVE = consultasSource.getConsultasSetupKey("fileActive");
        this.DESCRIPCION_MENSAJE_ALERTA_ORDEN_PROCESO = consultasSource.getConsultasSetupKey("descripcionMensajeAlertaOrdenProceso");
        this.FILE_ORIGIN_ORDEN_PROCESO = consultasSource.getConsultasSetupKey("fileOriginOrdenProceso");
        this.SIMPLE_DATE_FORMAT = new SimpleDateFormat(consultasSource.getConsultasSetupKey("simpleDateFormat"), this.LOCALE_DEFAULT);
        this.FILE_SEPARATOR = consultasSource.getConsultasSetupKey("fileSeparator");
        this.NOMBRE_CAMPO_CODIGO_BARRAS = consultasSource.getConsultasSetupKey("nombreCampoCodigoBarras");
        this.SHORT_SIMPLE_DATE_FORMAT = new SimpleDateFormat(consultasSource.getConsultasSetupKey("shortSimpleDateFormat"), this.LOCALE_DEFAULT);
        this.FILE_ORIGIN_GENERAR_BASE = consultasSource.getConsultasSetupKey("fileOriginGenerarBase");
        this.SHORT_SIMPLE_DATE_FORMAT_TO_HELP = new SimpleDateFormat(consultasSource.getConsultasSetupKey("shortSimpleDateFormatToHelp"), this.LOCALE_DEFAULT);
        this.FILE_SEPARATOR_TO_HELP = consultasSource.getConsultasSetupKey("fileSeparatorToHelp");
        this.SIMPLE_DATE_FORMAT_IMG = new SimpleDateFormat(consultasSource.getConsultasSetupKey("simpleDateFormatImg"), this.LOCALE_DEFAULT);
	this.PATH_GRAFICAS = consultasSource.getConsultasSetupKey("pathGraficas");
	this.FULL_PATH_GRAFICAS= consultasSource.getConsultasSetupKey("fullPathGraficas");
	this.DESCRIPCION_MENSAJE_ALERTA_BASE_CLIENTE=consultasSource.getConsultasSetupKey("descripcionMensajeAlertaBaseCliente");
        String ldapUsersFilter = consultasSource.getConsultasSetupKey("ldapUsersFilter");
        String[] ldapUsersFilterTokens = ldapUsersFilter.split(";");
        if (ldapUsersFilterTokens.length > 0) {
            this.LIST_LDAP_USERS_FILTER = new ArrayList();
            for (int i=0; i<ldapUsersFilterTokens.length; i++) {
                this.LIST_LDAP_USERS_FILTER.add(ldapUsersFilterTokens[i]);
            }
        }
        this.LIST_CODIGOS_CLIENTES_VIEW_RECLAMOS = new ArrayList();
        String codigosClientesViewReclamos = consultasSource.getConsultasSetupKey("codigosClientesViewReclamos");
        String[] codigosClientesViewReclamosTokens = codigosClientesViewReclamos.split(";");
        if (codigosClientesViewReclamosTokens.length > 0) {            
            for (int j=0; j<codigosClientesViewReclamosTokens.length; j++) {
                this.LIST_CODIGOS_CLIENTES_VIEW_RECLAMOS.add(codigosClientesViewReclamosTokens[j]);
            }
        }        
        this.LIST_CODIGOS_CALL_CENTER_BANNED_RECLAMOS = new ArrayList();
        String codigosCallCenterBannedReclamos = consultasSource.getConsultasSetupKey("codigosCallCenterBannedReclamos");
        String[] codigosCallCenterBannedReclamosTokens = codigosCallCenterBannedReclamos.split(";");
        if (codigosCallCenterBannedReclamosTokens.length > 0) {
            
            for (int j=0; j<codigosCallCenterBannedReclamosTokens.length; j++) {
                this.LIST_CODIGOS_CALL_CENTER_BANNED_RECLAMOS.add(codigosCallCenterBannedReclamosTokens[j]);
            }
        }
        float[] hsbBlue = Color.RGBtoHSB(84,85,255, null);
        float hue = hsbBlue[0];          
        float saturation = hsbBlue[1];   
        float brightness = hsbBlue[2];   
        this.LIGHT_BLUE=Color.getHSBColor(hue, saturation, brightness);
        float[] hsbGreen = Color.RGBtoHSB(85,255,86, null);
        hue = hsbGreen[0];         
        saturation = hsbGreen[1];   
        brightness = hsbGreen[2];  
        this.LIGHT_GREEN=Color.getHSBColor(hue, saturation, brightness);
        float[] hsbRed = Color.RGBtoHSB(255,100,100, null);
        hue = hsbRed[0];         
        saturation = hsbRed[1];   
        brightness = hsbRed[2];  
        this.LIGHT_RED=Color.getHSBColor(hue, saturation, brightness);
        float[] hsbYellow = Color.RGBtoHSB(255,255,85, null);
        hue = hsbYellow[0];         
        saturation = hsbYellow[1];   
        brightness = hsbYellow[2];       
        this.LIGHT_YELLOW=Color.getHSBColor(hue, saturation, brightness);
        this.CODIGO_GESTION_ENVIO_IMPRESION = consultasSource.getConsultasSetupKey("codigoGestionEnvioImpresion");
        try {
            this.NUMERO_REGISTROS_ZIP = Integer.valueOf(consultasSource.getConsultasSetupKey("numeroRegistrosZip")).intValue();
        }
        catch (NumberFormatException nFE) {
            this.NUMERO_REGISTROS_ZIP = 100000;
            xLogger.error("ConstantesGenerales:ConstantesGenerales:", nFE);
        }
    }

    public static ConstantesGenerales getInstance() {
        if (instance == null) {
            instance = new ConstantesGenerales();
        }
        return instance;
    }
}